package com.couldtest;


import com.github.kristofa.brave.Brave;
import com.github.kristofa.brave.mysql.MySQLStatementInterceptorManagementBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import zipkin.server.internal.EnableZipkinServer;
import zipkin.storage.mysql.MySQLStorage;

import javax.sql.DataSource;

@EnableEurekaClient
@EnableZipkinServer
@SpringBootApplication
public class ZipkinApplication {



	public static void main(String[] args) {
		SpringApplication.run(ZipkinApplication.class, args);
	}

	@Bean
	public MySQLStorage mySQLStorage(DataSource datasource) {
		return MySQLStorage.builder().datasource(datasource).executor(Runnable::run).build();
	}


	@Bean
	public MySQLStatementInterceptorManagementBean mySQLStatementInterceptorManagementBean() {
		Brave myBrave = new Brave.Builder("myBrave").build();
		return new MySQLStatementInterceptorManagementBean(myBrave.clientTracer());
	}

}
